Full source code website bán hàng thương mại điện tử gần giống shopee
468.809 lượt xem;
1 <?
2 include_once("fckeditor/fckeditor.php") ;
3 ?>
4 <?
5 //Check user's Browser
6 if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE"))
7 echo "<script language=JavaScript src='../inv/scripts/editor.js'></script>";
8 else
9 echo "<script language=JavaScript src='../inv/scripts/moz/editor.js'></script>";
10 ?>
11
12 <script>
13 function submitForm()
14 {
15 document.forms.FormLoaiSP.elements.content.value = oEdit1.getHTMLBody();
16 document.forms.FormLoaiSP.submit();
17 }
18 </script>
19
20 <?
21 $path = "../images/news";
22 $pathdb = "images/news";
23 if (isset($_POST['butSaveLoai'])) {
24 $name=$_POST['name'];
25 $short=$_POST['short'];
26 $desc=$_POST['desc'];
27 $cat=$_POST['cat'];
28 $thutu = $_POST['thutu'];
29 $date=date("d-m-Y");
30
31 $catinfo=GetCategoryInfo($categories_id);
32 $err="";
33 if ($name=="") $err .= "Xin nhập tên sản phẩm <br>";
34 $err.=CheckUpload($_FILES["txtImage"],".jpg;.gif;.png;.bmp",5000*1024,0);
35 $err.=CheckUpload($_FILES["txtImageLarge"],".jpg;.gif;.png;.bmp",5000*1024,0);
36
37 if ($err=='')
38 {
39 if (!empty($_POST['id'])) {
40 $oldid = $_POST['id'];
41 $sql = "update news set name='".$name."', short='".$short."', content='".$content."', cat_id='".$cat."', thutu='".$thutu."' where id='".$oldid."'";
42 }else {
43 $sql = "insert into news (name, short, content , cat_id, thutu,date) values ('".$name."','".$short."','".$content."','".$cat."','".$thutu."','".$date."')";
44 }
45 //echo $sql;
46 //exit();
47 if (mysql_query($sql,$con))
48 {
49 if(empty($_POST['id'])) {
50 $oldid = mysql_insert_id();
51 }
52
53 $sqlUpdateField = "";
54
55 $extsmall=GetFileExtention($_FILES['txtImage']['name']);
56 if (MakeUpload($_FILES['txtImage'],"$path/news_s$oldid$extsmall"))
57 {
58 @chmod("$path/news_s$oldid$extsmall", 0777);
59 $sqlUpdateField = " image='$pathdb/news_s$oldid$extsmall' ";
60 }
61
62 $extlarge=GetFileExtention($_FILES['txtImageLarge']['name']);
63 if (MakeUpload($_FILES['txtImageLarge'],"$path/news_l$oldid$extlarge"))
64 {
65 @chmod("$path/news_l$oldid$extlarge", 0777);
66 if($sqlUpdateField != "") $sqlUpdateField .= ",";
67 $sqlUpdateField .= " image_large='$pathdb/news_l$oldid$extlarge' ";
68 }
69 if($sqlUpdateField!='')
70 {
71 $sqlUpdate = "update news set $sqlUpdateField where id='".$oldid."'";
72 mysql_query($sqlUpdate,$con);
73 }
74 }
75 else {
76 $err = "Không thể cập nhật";
77 }
78 }
79
80 if ($err=='') echo '<script>window.location="index.php?act=news&status='.$_REQUEST['status'].'&cat='.$_REQUEST['cat'].'&page='.$_REQUEST['page'].'&code=1"</script>';
81 else echo "<p align=center class='err'>".$err."</p>";
82 } else {
83 ?>
84
85 <?
86 if (isset($_GET['id'])) {
87 $oldid=$_GET['id'];
88 $page = $_GET['page'];
89 $sql = "select * from news where id='".$oldid."'";
90 if ($result = mysql_query($sql,$con)) {
91 $row=mysql_fetch_array($result);
92 $name=$row['name'];
93 $image=$row['image'];
94 $categories_id = $row['cat_id'];
95 $imagelarge=$row['image_large'];
96 $short=$row['short'];
97 $desc=$row['content'];
98 $thutu=$row['thutu'];
99 }
100 }
101 }
102
103 ?>
104
105 <pre id="idTemporary" name="idTemporary" style="display:none">
106 <?
107 if(isset($content))
108 {
109 $sContent=stripslashes($content);//remove slashes (/)
110 echo $sContent;
111 }
112 ?>
113 </pre>
114
115
116
117 <pre id="idTemporaryen" name="idTemporaryen" style="display:none">
118 <?
119 if(isset($descen))
120 {
121 $sContent=stripslashes($descen);//remove slashes (/)
122 echo htmlentities($sContent);
123 }
124 ?>
125 </pre>
126
127 <script language="Javascript1.2"><!-- // load htmlarea
128 _editor_url = "htmlarea/"; // URL to htmlarea files
129 var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
130 if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
131 if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
132 if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
133 if (win_ie_ver >= 5.5) {
134 document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
135 document.write(' language="Javascript1.2"></scr' + 'ipt>');
136 } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
137 // --></script>
138
139 <form method="post" name="FormLoaiSP" enctype="multipart/form-data" action="index.php?">
140 <input type="hidden" name="content" id="content">
141 <input type="hidden" name="act" value="news_m">
142 <input type="hidden" name="id" value="<? echo $_REQUEST['id']; ?>">
143 <input type="hidden" name="page" value="<? echo $_REQUEST['page']; ?>">
144 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
145 <tr>
146 <td width="45%" class="title" align="center">Thêm mới / Cập nhật :
147 Sản phẩm</td>
148 </tr>
149 <tr>
150 <td width="45%">
151 <table border="0" cellpadding="2" bordercolor="#111111" width="100%" id="AutoNumber2" cellspacing="0">
152 <?
153 if ($image!='')
154 {
155 echo '<tr><td colspan="3" align="center"><img border="0" src="../'.$image.'"></td></tr>';
156 }
157 ?>
158 <tr>
159 <td width="15%" class="smallfont">
160 <p align="right">Tên sản phẩm</td>
161 <td width="1%" class="smallfont" align="center">
162 <font color="#FF0000">*</font></td>
163 <td width="83%" class="smallfont">
164 <INPUT value="<? echo $name; ?>" TYPE="text" NAME="name" CLASS=textbox size="89"></td>
165 </tr>
166
167 <tr>
168 <td width="15%" class="smallfont">
169 <p align="right">Hình nhỏ</td>
170 <td width="1%" class="smallfont" align="center">
171 <font color="#FF0000">*</font></td>
172 <td width="83%" class="smallfont">
173 <INPUT TYPE="file" NAME="txtImage" CLASS=textbox size="34"></td>
174 </tr>
175 <tr>
176 <td width="15%" class="smallfont">
177 <p align="right">Hình lớn</td>
178 <td width="1%" class="smallfont" align="center">
179 </td>
180 <td width="83%" class="smallfont">
181 <INPUT TYPE="file" NAME="txtImageLarge" CLASS=textbox size="34"></td>
182 </tr>
183 <td width="15%" class="smallfont" align="right">
184 Mô tả ngắn</td>
185 <td width="1%" class="smallfont" align="center">
186 </td>
187 <td width="83%" class="smallfont">
188 <textarea style="width:462; height:99" name="short" cols="4" cols="28"><? echo $short; ?></textarea>
189 </td>
190 </tr>
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205 <tr>
206 <td width="15%" class="smallfont" align="right">
207 Mô tả sản phẩm</td>
208 <td width="1%" class="smallfont" align="center">
209 </td>
210 <td width="83%" class="smallfont">
211 <?php
212 $oFCKeditor = new FCKeditor('desc') ;
213 $oFCKeditor->BasePath = 'fckeditor/' ;
214 $oFCKeditor->Value = $desc ;
215 $oFCKeditor->Create() ;
216 ?>
217 </td>
218 </tr>
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233 <tr>
234 <td width="15%" class="smallfont" align="right">
235 Thuộc danh mục</td>
236 <td width="1%" class="smallfont" align="center">
237 </td>
238 <td width="83%" class="smallfont">
239 <select size="1" name="cat" >
240 <?
241 $cats=GetListCatNews_admin(0);
242 foreach ($cats as $cat)
243 {
244 if ($cat[0]==$categories_id)
245 echo "<option value=".$cat[0]." selected>".$cat[1]."</option>";
246 else
247 echo "<option value=".$cat[0].">".$cat[1]."</option>";
248 }
249 ?>
250 </select>
251 </td>
252 </tr>
253 <tr>
254 <td width="15%" class="smallfont" align="right">
255 Thứ tự sắp xếp</td>
256 <td width="1%" class="smallfont" align="right">
257 </td>
258 <td width="83%" class="smallfont">
259 <INPUT value="<? echo $thutu; ?>" TYPE="text" NAME="thutu" CLASS=textbox size="20"></td>
260 </tr>
261 <tr>
262 <td width="15%" class="smallfont">
263 <p align="right">
264 <INPUT TYPE="submit" NAME="butSaveLoai" VALUE="Cập nhật" CLASS=button onclick="submitForm()"> </td>
265 <td width="1%" class="smallfont" align="center">
266 </td>
267 <td width="83%" class="smallfont"><p align="left"> <INPUT TYPE="reset" CLASS=button value="Nhập lại"></td>
268 </tr>
269 </table>
270 </td>
271 </tr>
272 </table>
273 </form>
2 include_once("fckeditor/fckeditor.php") ;
3 ?>
4 <?
5 //Check user's Browser
6 if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE"))
7 echo "<script language=JavaScript src='../inv/scripts/editor.js'></script>";
8 else
9 echo "<script language=JavaScript src='../inv/scripts/moz/editor.js'></script>";
10 ?>
11
12 <script>
13 function submitForm()
14 {
15 document.forms.FormLoaiSP.elements.content.value = oEdit1.getHTMLBody();
16 document.forms.FormLoaiSP.submit();
17 }
18 </script>
19
20 <?
21 $path = "../images/news";
22 $pathdb = "images/news";
23 if (isset($_POST['butSaveLoai'])) {
24 $name=$_POST['name'];
25 $short=$_POST['short'];
26 $desc=$_POST['desc'];
27 $cat=$_POST['cat'];
28 $thutu = $_POST['thutu'];
29 $date=date("d-m-Y");
30
31 $catinfo=GetCategoryInfo($categories_id);
32 $err="";
33 if ($name=="") $err .= "Xin nhập tên sản phẩm <br>";
34 $err.=CheckUpload($_FILES["txtImage"],".jpg;.gif;.png;.bmp",5000*1024,0);
35 $err.=CheckUpload($_FILES["txtImageLarge"],".jpg;.gif;.png;.bmp",5000*1024,0);
36
37 if ($err=='')
38 {
39 if (!empty($_POST['id'])) {
40 $oldid = $_POST['id'];
41 $sql = "update news set name='".$name."', short='".$short."', content='".$content."', cat_id='".$cat."', thutu='".$thutu."' where id='".$oldid."'";
42 }else {
43 $sql = "insert into news (name, short, content , cat_id, thutu,date) values ('".$name."','".$short."','".$content."','".$cat."','".$thutu."','".$date."')";
44 }
45 //echo $sql;
46 //exit();
47 if (mysql_query($sql,$con))
48 {
49 if(empty($_POST['id'])) {
50 $oldid = mysql_insert_id();
51 }
52
53 $sqlUpdateField = "";
54
55 $extsmall=GetFileExtention($_FILES['txtImage']['name']);
56 if (MakeUpload($_FILES['txtImage'],"$path/news_s$oldid$extsmall"))
57 {
58 @chmod("$path/news_s$oldid$extsmall", 0777);
59 $sqlUpdateField = " image='$pathdb/news_s$oldid$extsmall' ";
60 }
61
62 $extlarge=GetFileExtention($_FILES['txtImageLarge']['name']);
63 if (MakeUpload($_FILES['txtImageLarge'],"$path/news_l$oldid$extlarge"))
64 {
65 @chmod("$path/news_l$oldid$extlarge", 0777);
66 if($sqlUpdateField != "") $sqlUpdateField .= ",";
67 $sqlUpdateField .= " image_large='$pathdb/news_l$oldid$extlarge' ";
68 }
69 if($sqlUpdateField!='')
70 {
71 $sqlUpdate = "update news set $sqlUpdateField where id='".$oldid."'";
72 mysql_query($sqlUpdate,$con);
73 }
74 }
75 else {
76 $err = "Không thể cập nhật";
77 }
78 }
79
80 if ($err=='') echo '<script>window.location="index.php?act=news&status='.$_REQUEST['status'].'&cat='.$_REQUEST['cat'].'&page='.$_REQUEST['page'].'&code=1"</script>';
81 else echo "<p align=center class='err'>".$err."</p>";
82 } else {
83 ?>
84
85 <?
86 if (isset($_GET['id'])) {
87 $oldid=$_GET['id'];
88 $page = $_GET['page'];
89 $sql = "select * from news where id='".$oldid."'";
90 if ($result = mysql_query($sql,$con)) {
91 $row=mysql_fetch_array($result);
92 $name=$row['name'];
93 $image=$row['image'];
94 $categories_id = $row['cat_id'];
95 $imagelarge=$row['image_large'];
96 $short=$row['short'];
97 $desc=$row['content'];
98 $thutu=$row['thutu'];
99 }
100 }
101 }
102
103 ?>
104
105 <pre id="idTemporary" name="idTemporary" style="display:none">
106 <?
107 if(isset($content))
108 {
109 $sContent=stripslashes($content);//remove slashes (/)
110 echo $sContent;
111 }
112 ?>
113 </pre>
114
115
116
117 <pre id="idTemporaryen" name="idTemporaryen" style="display:none">
118 <?
119 if(isset($descen))
120 {
121 $sContent=stripslashes($descen);//remove slashes (/)
122 echo htmlentities($sContent);
123 }
124 ?>
125 </pre>
126
127 <script language="Javascript1.2"><!-- // load htmlarea
128 _editor_url = "htmlarea/"; // URL to htmlarea files
129 var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
130 if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
131 if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
132 if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
133 if (win_ie_ver >= 5.5) {
134 document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
135 document.write(' language="Javascript1.2"></scr' + 'ipt>');
136 } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
137 // --></script>
138
139 <form method="post" name="FormLoaiSP" enctype="multipart/form-data" action="index.php?">
140 <input type="hidden" name="content" id="content">
141 <input type="hidden" name="act" value="news_m">
142 <input type="hidden" name="id" value="<? echo $_REQUEST['id']; ?>">
143 <input type="hidden" name="page" value="<? echo $_REQUEST['page']; ?>">
144 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
145 <tr>
146 <td width="45%" class="title" align="center">Thêm mới / Cập nhật :
147 Sản phẩm</td>
148 </tr>
149 <tr>
150 <td width="45%">
151 <table border="0" cellpadding="2" bordercolor="#111111" width="100%" id="AutoNumber2" cellspacing="0">
152 <?
153 if ($image!='')
154 {
155 echo '<tr><td colspan="3" align="center"><img border="0" src="../'.$image.'"></td></tr>';
156 }
157 ?>
158 <tr>
159 <td width="15%" class="smallfont">
160 <p align="right">Tên sản phẩm</td>
161 <td width="1%" class="smallfont" align="center">
162 <font color="#FF0000">*</font></td>
163 <td width="83%" class="smallfont">
164 <INPUT value="<? echo $name; ?>" TYPE="text" NAME="name" CLASS=textbox size="89"></td>
165 </tr>
166
167 <tr>
168 <td width="15%" class="smallfont">
169 <p align="right">Hình nhỏ</td>
170 <td width="1%" class="smallfont" align="center">
171 <font color="#FF0000">*</font></td>
172 <td width="83%" class="smallfont">
173 <INPUT TYPE="file" NAME="txtImage" CLASS=textbox size="34"></td>
174 </tr>
175 <tr>
176 <td width="15%" class="smallfont">
177 <p align="right">Hình lớn</td>
178 <td width="1%" class="smallfont" align="center">
179 </td>
180 <td width="83%" class="smallfont">
181 <INPUT TYPE="file" NAME="txtImageLarge" CLASS=textbox size="34"></td>
182 </tr>
183 <td width="15%" class="smallfont" align="right">
184 Mô tả ngắn</td>
185 <td width="1%" class="smallfont" align="center">
186 </td>
187 <td width="83%" class="smallfont">
188 <textarea style="width:462; height:99" name="short" cols="4" cols="28"><? echo $short; ?></textarea>
189 </td>
190 </tr>
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205 <tr>
206 <td width="15%" class="smallfont" align="right">
207 Mô tả sản phẩm</td>
208 <td width="1%" class="smallfont" align="center">
209 </td>
210 <td width="83%" class="smallfont">
211 <?php
212 $oFCKeditor = new FCKeditor('desc') ;
213 $oFCKeditor->BasePath = 'fckeditor/' ;
214 $oFCKeditor->Value = $desc ;
215 $oFCKeditor->Create() ;
216 ?>
217 </td>
218 </tr>
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233 <tr>
234 <td width="15%" class="smallfont" align="right">
235 Thuộc danh mục</td>
236 <td width="1%" class="smallfont" align="center">
237 </td>
238 <td width="83%" class="smallfont">
239 <select size="1" name="cat" >
240 <?
241 $cats=GetListCatNews_admin(0);
242 foreach ($cats as $cat)
243 {
244 if ($cat[0]==$categories_id)
245 echo "<option value=".$cat[0]." selected>".$cat[1]."</option>";
246 else
247 echo "<option value=".$cat[0].">".$cat[1]."</option>";
248 }
249 ?>
250 </select>
251 </td>
252 </tr>
253 <tr>
254 <td width="15%" class="smallfont" align="right">
255 Thứ tự sắp xếp</td>
256 <td width="1%" class="smallfont" align="right">
257 </td>
258 <td width="83%" class="smallfont">
259 <INPUT value="<? echo $thutu; ?>" TYPE="text" NAME="thutu" CLASS=textbox size="20"></td>
260 </tr>
261 <tr>
262 <td width="15%" class="smallfont">
263 <p align="right">
264 <INPUT TYPE="submit" NAME="butSaveLoai" VALUE="Cập nhật" CLASS=button onclick="submitForm()"> </td>
265 <td width="1%" class="smallfont" align="center">
266 </td>
267 <td width="83%" class="smallfont"><p align="left"> <INPUT TYPE="reset" CLASS=button value="Nhập lại"></td>
268 </tr>
269 </table>
270 </td>
271 </tr>
272 </table>
273 </form>